package com.nantian.ecm.idcard.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.nantian.ecm.idcard.domain.IDCard;

@RestController()
@RequestMapping("/idcards")
public class IDCardController {

	@RequestMapping(method = RequestMethod.GET, value = "/{id}")
	public IDCard get(@PathVariable("id") String id) {
		IDCard id1 = new IDCard();
		id1.setId(id);
		id1.setName("张三");
		return id1;
	}

	@RequestMapping(method = RequestMethod.GET, value = "")
	public List<IDCard> list() {
		IDCard id1 = new IDCard();
		id1.setId("1111111");
		id1.setName("张三");

		IDCard id2 = new IDCard();
		id2.setId("2222222");
		id2.setName("李四");

		ArrayList<IDCard> list = new ArrayList<IDCard>();
		list.add(id1);
		list.add(id2);
		return list;
	}

	@RequestMapping(method = RequestMethod.POST)
	public IDCard add(@RequestBody IDCard idcard) {
		return idcard;
	}

	@RequestMapping(method = RequestMethod.PUT, value = "/{id}")
	public IDCard update(@RequestBody IDCard idcard, @PathVariable("id") String id) {
		idcard.setId(id);
		return idcard;
	}
	
	@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
	public IDCard delete(@PathVariable("id") String id) {
		return null;
	}
	
}
